package com.mobilezu.mobile.android.mobile4s.view.slidingmenu.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.mobilezu.mobile.android.mobile4s.R;
/**
 * Main menu item management class,code start with0x0006x
 * @author leo.wang
 * @create 2013-5-31
 * @version 1.0.0
 */
public class MainMenuFragment extends Fragment {
	private ImageButton ivSeach;
	private ImageButton ivMessage;
	private ImageButton ivSetting;
	private ImageButton miv_photo;
//	private Button btnAccount;
//	private Button btnAbout;
	private View view;
	private OnMenuItemClickListener onMenuItemClickListener;
	public static final int VIEW_MESSAGE_CODE=0x00061;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.main_menu_layout, null);
		initViews();
		return view;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		initListener();
	}
	
	/**
	 * Initialize view control
	 */
	private void initViews(){
		ivSeach=(ImageButton)view.findViewById(R.menu_layout.miv_seach);
		ivMessage=(ImageButton)view.findViewById(R.menu_layout.miv_message);
		ivSetting=(ImageButton)view.findViewById(R.menu_layout.miv_setting);
		miv_photo=(ImageButton)view.findViewById(R.menu_layout.miv_about);
//		btnAccount=(Button)view.findViewById(R.menu_layout.btn_account);
//		btnAbout=(Button)view.findViewById(R.menu_layout.btn_about);
	}
	
	/**
	 * Initialize menu item click listener
	 */
	private  void initListener() {
		ivSeach.setOnClickListener(onItemListener);
		ivMessage.setOnClickListener(onItemListener);
		ivSetting.setOnClickListener(onItemListener);
		miv_photo.setOnClickListener(onItemListener);
//		btnAccount.setOnClickListener(onItemListener);
//		btnAbout.setOnClickListener(onItemListener);
	}
	
	/**
	 *Set on seach menu item click listener 
	 * @param onSeachItemClickListener on menu item click listener
	 */
	public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener){
		this.onMenuItemClickListener=onMenuItemClickListener;
	}
	
	//Set on seach button click listener
	private OnClickListener onItemListener=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			if(onMenuItemClickListener!=null){
				onMenuItemClickListener.onClick(v);
			}
		}
	};
	
	/**On Seach Menu item click listener*/
	public interface OnMenuItemClickListener{
		public void onClick(View view);
	}
	
}
